s = "abcdefg"
k = 2

# 输入：s = "abcdefg", k = 2
# 输出："bacdfeg"

class Solution:
    def reverseStr(self, s: str, k: int) -> str:
        t = list(s)
        for i in range(0, len(t), 2 * k):
            t[i: i + k] = reversed(t[i: i + k])
        return "".join(t)


res = Solution()
print(res.reverseStr(s, k))
